home *** CD-ROM | disk | FTP | other *** search
- Path: engnews1.Eng.Sun.COM!taumet!clamage
- From: "joe (j.) halpin" <jhalpin@bnr.ca>
- Newsgroups: comp.std.c++
- Subject: Referencing pointers after delete
- Date: 21 Mar 1996 16:29:49 GMT
- Organization: Bell-Northern Research, Richardson, TX
- Approved: clamage@eng.sun.com (comp.std.c++)
- Message-ID: <4is05t$ceo@engnews1.Eng.Sun.COM>
- NNTP-Posting-Host: taumet.eng.sun.com
- Content-Length: 1158
- X-Lines: 38
- Cc:
- Originator: clamage@taumet
-
- To Moderator: This may be a duplicate, my newsreader software was having
- trouble sending this, so I'm mailing it as well.
-
- In 3.7.3.2.4 the January working paper says:
-
- 4 A deallocation function can free the storage referenced by the pointer
- given as its argument and renders the pointer invalid. The storage
- can be made available for further allocation. An invalid pointer con-
- tains an unusable value: it cannot even be used in an expression.
-
- This sounds as though, in the following:
-
- char *pc = new char[128];
- delete pc;
- pc = 0;
-
- it makes the final assignment (an expression) invalid.
-
- Am I misunderstanding something, or is it illegal to zero out pointers
- after they've been deallocated? I'm assuming that the intent was to
- disallow dereferencing of pointers that have been handed to
- delete. The wording seems to disallow the above as well.
-
- In fact, it sounds like it also rules out things like 'if(pc == 0)
- ...' after the above fragment.
-
- Joe
-
-
- [ comp.std.c++ is moderated. To submit articles: try just posting with ]
- [ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
- [ FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html ]
- [ Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
- [ Comments? mailto:std-c++-request@ncar.ucar.edu ]
-